package models

import (
	"errors"
	"github.com/jinzhu/gorm"
)

//表字段结构体
type Users struct {
	Id			int64		`gorm:"primary_key;column:id;type:int(11) unsigned;not null"`
	Username	string		`gorm:"column:username;type:varchar(50);not null;"`
}

func (u *Users) TableName() string {
	return "gb_users"
}

//表增删改查操作
type UsersDao struct {
	tx *gorm.DB
}

//查看某条记录
func (t *UsersDao) GetOne(username string) (one *Users, err error) {
	one = &Users{}
	if t.tx.Where("username = ?", username).First(one).RecordNotFound() {
		return nil, errors.New("record not find")
	}
	return
}





